home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / PROGRAMS / CH4 / 4-2-2.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-11-02  |  2.7 KB  |  94 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAdd 
  3.    Caption         =   "Add Two Numbers"
  4.    ClientHeight    =   1695
  5.    ClientLeft      =   3300
  6.    ClientTop       =   3060
  7.    ClientWidth     =   2775
  8.    BeginProperty Font 
  9.       Name            =   "MS Sans Serif"
  10.       Size            =   8.25
  11.       Charset         =   0
  12.       Weight          =   700
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    LinkTopic       =   "Form1"
  18.    PaletteMode     =   1  'UseZOrder
  19.    ScaleHeight     =   1695
  20.    ScaleWidth      =   2775
  21.    Begin VB.PictureBox picResult 
  22.       AutoRedraw      =   -1  'True
  23.       Height          =   255
  24.       Left            =   120
  25.       ScaleHeight     =   195
  26.       ScaleWidth      =   2475
  27.       TabIndex        =   5
  28.       Top             =   1320
  29.       Width           =   2535
  30.    End
  31.    Begin VB.CommandButton cmdCompute 
  32.       Caption         =   "Compute Sum"
  33.       Height          =   375
  34.       Left            =   600
  35.       TabIndex        =   4
  36.       Top             =   840
  37.       Width           =   1575
  38.    End
  39.    Begin VB.TextBox txtSecondNum 
  40.       Height          =   285
  41.       Left            =   1680
  42.       TabIndex        =   1
  43.       Top             =   480
  44.       Width           =   975
  45.    End
  46.    Begin VB.TextBox txtFirstNum 
  47.       Height          =   285
  48.       Left            =   1680
  49.       TabIndex        =   0
  50.       Top             =   120
  51.       Width           =   975
  52.    End
  53.    Begin VB.Label lblSecondNum 
  54.       AutoSize        =   -1  'True
  55.       Caption         =   "Second Number"
  56.       Height          =   195
  57.       Left            =   240
  58.       TabIndex        =   3
  59.       Top             =   480
  60.       Width           =   1365
  61.    End
  62.    Begin VB.Label lblFirstNum 
  63.       AutoSize        =   -1  'True
  64.       Caption         =   "First Number"
  65.       Height          =   195
  66.       Left            =   480
  67.       TabIndex        =   2
  68.       Top             =   120
  69.       Width           =   1095
  70.    End
  71. Attribute VB_Name = "frmAdd"
  72. Attribute VB_GlobalNameSpace = False
  73. Attribute VB_Creatable = False
  74. Attribute VB_PredeclaredId = True
  75. Attribute VB_Exposed = False
  76. Private Sub cmdCompute_Click()
  77.   Dim x As Single, y As Single
  78.   'Display the sum of the two numbers
  79.   Call GetNumbers(x, y)
  80.   Call Add(x, y)
  81. End Sub
  82. Private Sub Add(num1 As Single, num2 As Single)
  83.   Dim sum As Single
  84.   'Display numbers and their sum
  85.   picResult.Cls
  86.   sum = num1 + num2
  87.   picResult.Print "The sum of"; num1; "and"; num2; "is"; sum
  88. End Sub
  89. Private Sub GetNumbers(num1 As Single, num2 As Single)
  90.   'Record the two numbers in the text boxes
  91.   num1 = Val(txtFirstNum.Text)
  92.   num2 = Val(txtSecondNum.Text)
  93. End Sub
  94.